123456789112233k<template>
  <div id="app">
    <router-view />
  </div>
</template>
<style lang="less" scoped>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  color: #2c3e50;
  height: 100%;
  background: #f2f5f8;
}
</style>
<script>
export default {
  created() {
    this.addScript('webview')
    this.setFontSize(document, window)
  },
  methods: {
    addScript(name) {
      let head = document.getElementsByTagName('head')[0]
      let script = document.createElement('script')
      script.type = 'text/javascript'
      script.onload = script.onreadystatechange = () => {
        if (name === 'webview') {
          // console.log('uni', uni) //eslint-disable-line
        }
      }
      script.src = `/static/js/${name}.js`
      head.appendChild(script)
    },
    setFontSize(doc, win) {
      let docEl = doc.documentElement
      let resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
      let reCaculate = function() {
        let clientWidth = docEl.clientWidth
        if (!clientWidth) {
          return
        }
        docEl.style.fontSize = 100 * (clientWidth / 360) + 'px'
      }
      if (!doc.addEventListener) {
        return
      }
      win.addEventListener(resizeEvt, reCaculate, false)
      doc.addEventListener('DOMContentLoaded', reCaculate, false)
    }
  }
}
</script>
